package com.xinruke.hostels.report.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.report.service.SingleQueryService;
import com.xinruke.hostels.reportinterfaces.dto.SingleConditionQueryDTO;
import com.xinruke.hostels.reportinterfaces.dto.SingleConditionQueryResultDTO;
import com.xinruke.hostels.reportinterfaces.dto.SingleQueryDTO;
import com.xinruke.hostels.reportinterfaces.dto.SingleQueryResultDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @ClassName SingleQueryController
 * @CreateDate 2019/8/6
 * @Author FengXinQiang
 * @Version V1.0.0.0
 * @Decription 单一查询Controller
 */
@RestController
@RequestMapping("single/query")
@Api(tags = "单一查询")
public class SingleQueryController extends BaseController {
    @Autowired
    SingleQueryService singleQueryService;

    @PostMapping("/queryOrderField")
    @ApiOperation("获取查询和排序的字段信息")
    public SingleConditionQueryResultDTO getQueryOrderField(@Valid @RequestBody SingleConditionQueryDTO singleConditionQueryDTO) {
        return singleQueryService.getQueryOrderField(singleConditionQueryDTO);
    }

    @PostMapping("/list")
    @ApiOperation("查询数据列表")
    public SingleQueryResultDTO getList(@Valid @RequestBody SingleQueryDTO singleQueryDTO) {
        return singleQueryService.getList(singleQueryDTO);
    }
}
